import numpy as np import cv2 import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation, PillowWriter # Load and resize the image image_path = 'your_image_path_here' # replace with your image path image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE) image_small = cv2.resize(image, (1920, 1080)) # Resize to 1080p # Create a figure for the plot fig, ax = plt.subplots() # Initialize the plot with the first frame im = ax.imshow(image_small, cmap='gray') def update(i): # Create a Hann window window = np.hanning(image_small.shape[1]) # Apply the window to the current slice of the image image_windowed = image_small.copy() image_windowed[:, i] = image_small[:, i] * window[i] # Update the plot im.set_array(image_windowed) # Create an animation ani = FuncAnimation(fig, update, frames=np.arange(0, image_small.shape[1])) # Save the animation as a GIF gif_path = 'windowing.gif' # replace with your preferred path ani.save(gif_path, writer=PillowWriter(fps=60)) # 60 FPS